from langchain_core.tools import Tool


def search_api(query, num=5):
    # return f"要搜索的内容:{query*num}"
    return len(query)


search_tool = Tool(
    name="api搜索工具",
    description="根据用户输入的字符串发起网络请求，返回信息",
    func=search_api,
)

result = search_tool.invoke("今天天气怎么样")

print(search_tool.name, 'search_tool.name')
print(search_tool.description, 'search_tool.description')
print(search_tool.func, 'search_tool.func')
print(type(result), 'result 类型')
print(result, 'result')
